package String;

public class Test {
    public static void main(String[] args) {
        // 截取域名
        String url = "https://www.baidu.com";
        String url1 ="https://www.google.com";
        String url2 = "https://www.openai.com";
        String url3 = "https://www.bing.com";
        System.out.println(getDomain(url));
        System.out.println(getDomain(url1));
        System.out.println(getDomain(url2));
        System.out.println(getDomain(url3));

    }
    public static String getDomain(String url) {
        // 找到第一个.的位置
        int index = url.indexOf(".");
        // 找到第二个.的位置
        int index1 = url.indexOf(".", index + 1);

        return url.substring(index + 1,index1);
    }
}
